- Posterior Updating (Or: Is my cat a picky eater?)
- Priors for estimation
- Priors for model comparison (Or: Is my cat fat?)
- Prior prediction and prior sensitivity
Is Frank a picky eater?
\[Y \sim \mbox{Binomial}(\theta, 30),\] \[\theta = .5.\]
\[Y \sim \mbox{Binomial}(\theta,30), \qquad \theta = .5.\]
Let’s say he ate 21 out of 30 meals. \(Y = 21.\)
In Bayesian statistical analysis we typically would use a prior distribution for parameters. \[ \begin{aligned} Y|\theta &\sim \mbox{Binomial}(\theta,N),\\ \theta &\sim \mbox{Beta}(a,b). \end{aligned} \]
If we assume Frank will most likely eat 5 out of 10 meals we may use \(a = 5\) and \(b = 5\).
from \(Pr(\theta)\)…
from \(Pr(\theta)\)… to \(Pr(\theta|Y)\).
\[ Pr(\theta|Y) = Pr(\theta)\frac{Pr(Y|\theta)}{Pr(Y)} \]
What should it look like?
\[\theta \sim \mbox{Uniform}(0, 1).\]
theta <- runif(100000) hist(theta, probability = T)
What are the odds of Frank eating the food, \(OR = \frac{\theta}{1 - \theta}\)?
Suppose \(\theta\) does not have constrained support (mean difference between two measures): \[\theta \sim \mbox{Uniform}(-\infty, \infty).\]
theta <- runif(100000, min = -100000, max = 100000) hist(theta, probability = T, ylim = c(0, 1))
Frank eats his food 7 out of 10 times.
Frank eats his food 21 out of 30 times.
Frank eats his food 650 out of 1000 times.
Frank might be picky, but once we figured out what he likes he is getting pretty fat. So we put him on a diet for 30 days.
| Day | ||
|---|---|---|
| day 1 | 7.2 | NA |
| day 2 | 7.12 | -0.08 |
| day 3 | 7.07 | -0.05 |
| day 4 | 7.19 | 0.13 |
| day 5 | 7.17 | -0.02 |
| day 6 | 7.16 | -0.01 |
| day 7 | 7.3 | 0.14 |
| day 8 | 7.32 | 0.02 |
| day 9 | 7.17 | -0.15 |
| day 10 | 7.07 | -0.1 |
| day 11 | 7 | -0.07 |
| day 12 | 7.09 | 0.09 |
| day 13 | 7.1 | 0.01 |
| day 14 | 7.11 | 0.01 |
| day 15 | 7.1 | -0.02 |
| day 16 | 7.01 | -0.08 |
| day 17 | 7.17 | 0.15 |
| day 18 | 7.19 | 0.02 |
| day 19 | 6.96 | -0.22 |
| day 20 | 7.01 | 0.04 |
| day 21 | 6.93 | -0.07 |
| day 22 | 6.8 | -0.13 |
| day 23 | 6.75 | -0.05 |
| day 24 | 6.62 | -0.13 |
| day 25 | 6.52 | -0.1 |
| day 26 | 6.43 | -0.09 |
| day 27 | 6.23 | -0.2 |
| day 28 | 6.29 | 0.06 |
| day 29 | 6.27 | -0.01 |
| day 30 | 6.13 | -0.14 |
1/30
## [1] 0.03333333
BayesFactor package in R and JASP use default priors for the t-test called JZS prior.BayesFactor package in R and JASP use default priors for the t-test called JZS prior.BayesFactor::ttestBF(x = Change[-1]
, mu = 0
, nullInterval = c(-Inf, 0)
, rscale = 1/sqrt(2))
BayesFactor::ttestBF(x = Change[-1]
, mu = 0
, nullInterval = c(-Inf, 0)
, rscale = 1/sqrt(2))
BayesFactor::ttestBF(x = Change[-1]
, mu = 0
, nullInterval = c(-Inf, 0)
, rscale = 1/3)
BayesFactor::ttestBF(x = Change[-1]
, mu = 0
, nullInterval = c(-Inf, 0)
, rscale = 1/3)
## Bayes factor analysis ## -------------- ## [1] Alt., r=0.333 -Inf<d<0 : 3.095844 ±0% ## [2] Alt., r=0.333 !(-Inf<d<0) : 0.1448153 ±0% ## ## Against denominator: ## Null, mu = 0 ## --- ## Bayes factor type: BFoneSample, JZS
| a | b |
|---|---|
| 0.3 | 1.1 |
| 0.5 | 1.1 |
| 0.7 | 1.1 |
| 0.3 | 1.5 |
| 0.5 | 1.5 |
| 0.7 | 1.5 |
| 0.3 | 1.9 |
| 0.5 | 1.9 |
| 0.7 | 1.9 |
\[Y \sim \mbox{Binomial}(\theta,30), \qquad \theta = .5.\]
M <- 1000 # simulation runs p.theta <- rbeta(M, 2, 2) # theta sampled from the prior y <- rbinom(1000, 100, p.theta) hist(y)